package foundation.SurModel.rndForest.sample;

import java.util.ArrayList;
import java.util.List;

import weka.core.Instance;
import weka.core.Instances;

public class RelbLearnTblItem {
	// int solveNum = 1;////求解可靠性指标的次数
	// 处理器速度为float类；服务器名为编号；组件选择中组件名为编号
	List<StringBuffer> mlDFcodes = new ArrayList<StringBuffer>();
	float actualRelbVal = -1f;// 可靠性指标的真实值
	float predictRelbVal = -1f;// 可靠性指标的预测值

	private static List<String> attrNames = new ArrayList<String>();
	private static ArrayList<Integer> strtIdxs = new ArrayList<Integer>();

	public static List<String> getAttrs() {
		if(attrNames.size()==0){
			attrNames = new ArrayList<String>();
			for(int i=0;i<strtIdxs.get(strtIdxs.size()-1)+2;i++){
				attrNames.add("Column"+(i+1));
			}
		}
		return attrNames;
	}

	public ArrayList<Double> toDblList() {
		ArrayList<Double> data = new ArrayList<Double>();
		for(int i=0;i<getMlDFcodes().size();i++){
			data.add(Double.parseDouble(getMlDFcodes().get(i).toString()));
		}
		data.add((double)getActualRelbVal());
		return data;
	}

	public Instance getInstance() {
		ArrayList<ArrayList<Double>> data = new ArrayList<ArrayList<Double>>();
		data.add(toDblList());
		Instances instances = null;
		try {
			instances = ConverterData.converterData(getAttrs(), data);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return instances.get(0);
	}

	public List<StringBuffer> getMlDFcodes() {
		return mlDFcodes;
	}

	public void setMlDFcodes(List<StringBuffer> mlDFcodes) {
		this.mlDFcodes = mlDFcodes;
	}

	public float getActualRelbVal() {
		return actualRelbVal;
	}

	public void setActualRelbVal(float actualRelbVal) {
		this.actualRelbVal = actualRelbVal;
	}

	public float getPredictRelbVal() {
		return predictRelbVal;
	}

	public void setPredictRelbVal(float predictRelbVal) {
		this.predictRelbVal = predictRelbVal;
	}

	public static ArrayList<Integer> getStrtIdxs() {
		return strtIdxs;
	}

	public static void setStrtIdxs(ArrayList<Integer> strtIdxs) {
		RelbLearnTblItem.strtIdxs = strtIdxs;
	}

}
